1. Field of the Invention
The present invention relates to a magnetic sensor including a magnetic detection element and two bias magnetic field generation units, the two bias magnetic field generation units being configured to cooperate with each other to generate a bias magnetic field to be applied to the magnetic detection element.
2. Description of the Related Art
In recent years, magnetic sensor systems have been employed to detect a physical quantity associated with the rotational movement or linear movement of a moving object in a variety of applications. Typically, a magnetic sensor system includes a scale and a magnetic sensor, and the magnetic sensor is configured to generate a signal associated with the relative positional relationship between the scale and the magnetic sensor.
The magnetic sensor includes a magnetic detection element for detecting a magnetic field to be detected. Hereinafter, the magnetic field to be detected will be referred to as the target magnetic field. U.S. Patent Application Publication No. 2014/0292322 A1 discloses a magnetic sensor that uses a so-called spin-valve magnetoresistance (MR) element as the magnetic detection element. The spin-valve MR element includes a magnetization pinned layer having a magnetization pinned in a certain direction, a free layer having a magnetization that varies depending on the target magnetic field, and a nonmagnetic layer located between the magnetization pinned layer and the free layer. Examples of the spin-valve MR element include a TMR element in which the nonmagnetic layer is a tunnel barrier layer, and a GMR element in which the nonmagnetic layer is a nonmagnetic conductive layer.
Some magnetic sensors have means for applying a bias magnetic field to the magnetic detection element. The bias magnetic field is used to allow the magnetic detection element to respond linearly to a variation in the strength of the target magnetic field. In a magnetic sensor that uses a spin-valve MR element, the bias magnetic field is used also to make the free layer have a single magnetic domain and to orient the magnetization of the free layer in a certain direction, when there is no target magnetic field.
U.S. Patent Application Publication No. 2014/0292322 A1 discloses a magnetic sensor including a spin-valve MR element, and a pair of permanent magnets for generating a bias magnetic field. The pair of permanent magnets are opposed to each other with the MR element therebetween.
Magnetic sensors that use a pair of permanent magnets as the means for generating a bias magnetic field, such as those disclosed in U.S. Patent Application Publication No. 2014/0292322 A1, have the following problems. Such magnetic sensors are typically used under the condition that the strength of the target magnetic field does not exceed the coercivity of the permanent magnets. However, since the magnetic sensors can be used in various environments, an external magnetic field having a strength exceeding the coercivity of the permanent magnets can happen to be temporarily applied to the permanent magnets. When such an external magnetic field is temporarily applied to the permanent magnets, the magnetization direction of the permanent magnets may be changed from an original direction and then remain different from the original direction even after the external magnetic field disappears. In such a case, the direction of the bias magnetic field differs from a desired direction.